package com.ming.mq.direct;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DirectConfig {
    public static final String DIRECTQUEUE1 = "queue_direct1";
    public static final String DIRECTQUEUE2 = "queue_direct2";

    public static final String EXCHANGE = "directExchange";

    public static final String ROUTINGKEY1 = "queue.one";
    public static final String ROUTINGKEY2 = "queue.two";

    @Bean
    public Queue queue1(){
        return new Queue(DIRECTQUEUE1);
    }

    @Bean
    public Queue queue2(){
        return new Queue(DIRECTQUEUE2);
    }

    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange(EXCHANGE);
    }

    @Bean
    public Binding binding1(){
        return BindingBuilder
                .bind(queue1())
                .to(directExchange())
                .with(ROUTINGKEY1);
    }

    @Bean
    public Binding binding2(){
        return BindingBuilder
                .bind(queue2())
                .to(directExchange())
                .with(ROUTINGKEY2);
    }


}
